Formatting a section or report object conditionally

You can now do conditional formatting using VB code. Crystal Reports has allowed this in the past with its own formula language but now you can do it in VB code as well.

This Format event is fired each time this section is formatted, so you can get the values of the object and perform a variety of formatting functions.

This first example changes the backcolor of the section itself if the value of the selected field is less than 50000.

Private Sub Section6_Format(ByVal pFormattingInfo As Object)
If Field9.Value < 50000 Then
        Section6.BackColor = vbRed
    Else
        Section6.BackColor = vbWhite
    End If
End Sub

The second example changes the color of the text in the selected field if the value of that field is less than 50000.

Private Sub Section6_Format(ByVal pFormattingInfo As Object)
If Field9.Value < 50000 Then
        Field9.TextColor = vbRed
    Else
        Field9.TextColor = vbGreen
    End If
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com